class TrunkNode {
public:
	// A wire with start and end points, labeled netNum
	CellType netNum;
	CellType start;
	CellType end;
	bool start_up; // whether the end routes up or down
	bool end_up;
	TrunkNode(CellType net, CellType endPoint0, CellType endPoint1, bool s_up, bool e_up) {
		netNum = net;
		start = endPoint0;
		end = endPoint1;
		start_up = s_up;
		end_up = e_up;
	}

	TrunkNode() {
		netNum = -1;
		start = -1;
		end = -1;
	}

	bool collide(TrunkNode node2) {
		// 4 ways a wire can collide with another
		//		o-----------o
		// 1. o----o
		// 2.             o----o
		// 3.       o----o
		// 4. o----------------o
		//
		//    (start)------(end)
		//
		// If either endpoint of wire 2 is inside wire 1, collsion
		// If endpoints of wire 2 are left and right of wire 1, collision
		bool collision = false;
		if((end >= node2.start) && (end <= node2.end)) { // 1
			collision = true;
		}
		else if((start >= node2.start) && (start <= node2.end)) { // 2, 3 is accounted for in these 2
			collision = true;
		}
		else if((start <= node2.start) && (end >= node2.end)) { // 4
			collision = true;
		}
		return collision;
	}
};

class MagicWire {
public:
	// A wire with start and end points, labeled netNum
	CellType position[4];

	MagicWire(CellType bottomX, CellType bottomY, CellType topX, CellType topY) {
		position[0] = bottomX;
		position[1] = bottomY;
		position[2] = topX;
		position[3] = topY;
	}

	MagicWire() {
		position[0] = -1;
		position[1] = -1;
		position[2] = -1;
		position[3] = -1;
	}
};

class MagicCell {
public:
	// A wire with start and end points, labeled netNum
	bool mirror;
	CellType cellNum;
	CellType posX, posY;

	MagicCell(CellType cellNum_in, CellType posX_in, CellType posY_in, bool mirror_in) {
		cellNum = cellNum_in;
		posX = posX_in;
		posY = posY_in;
		mirror = mirror_in;
	}

	MagicCell() {
		posX = -1;
		posY = -1;
		mirror = false;
	}
};